<?php 
    include("header.php");
    setTabIndex(1);
    createPage("Liga - Nieuwsbericht");
    
    $newsId = $_GET['newsId'];
    mysql_connect(DB_SERVER, DB_USER, DB_PWD);
    mysql_select_db(DB_CATALOG);
    $result = mysql_query("SELECT ni.news_id, ni.title, ni.introImage, DATE_FORMAT(ni.date,'%e/%m/%Y %k:%i:%s') as date, ".
                "ni.intro, ni.message, u.username FROM news_item AS ni JOIN news_history AS nh ".
                "ON ni.news_id = nh.news_id JOIN user AS u ON nh.user_id = u.user_id ".
                "WHERE ni.news_id = ".$newsId." ORDER BY DATE DESC");
    $row = mysql_fetch_assoc($result);

    $newsItem = new NewsItem;
    $newsItem->news_id = $row['news_id'];
    $newsItem->title = $row['title'];
    $newsItem->date = $row['date'];
    $newsItem->intro = $row['intro'];
    $newsItem->introImage = $row['introImage'];
    $newsItem->message = $row['message'];
    $newsItem->author = $row['username'];
    
    if ( isValidURL($newsItem->introImage) ) {
        $newsItem->intro = "<table><tr valign=top><td><img src=".$newsItem->introImage." height=60 /></td><td>".$row['intro']."</td></tr></table>";
    }
?>

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">

    <tr>
        <td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#006633">
            <table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">
                <tr><td>&nbsp;</td></tr>
            </table>
        </td>
        <td id="header" valign="top" width="100%">
            <table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
                <tr>
                    <td bgcolor="#006633" width="70%">
                        <?php include("inc_title.html"); ?>
                    </td>
                    <td bgcolor="#006633" align="right">&nbsp;
                    <?php
                        if (isset($user)) {
                    ?>
                        <a href="insert_news_form.php"><img src="assets/images/16x16/add.gif" border="0" alt="Voeg nieuwsbericht toe"></a>
                        &nbsp;&nbsp;
                    <?php
                        }
                    ?>
                    </td>
                </tr>
            </table>
            <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
                <tr>
                    <?php include("inc_sublinks.html"); ?>   
                </tr>
                <tr><td colspan="3" nowrap bgcolor="#BCDD10" height="4"><img src="/assets/images/spacer.gif" alt="" height="1" width="1"></td></tr>
                <tr>
                    <td>&nbsp;</td>
                    <td width="90%" valign="top">
                        <table cellspacing="2" cellpadding="5" class="newsbox">
                            <tr >
                                <td valign="top">
                                    <h3><?=$newsItem->title?></h3>
                                    <span class="newsDate">Gepost door: <em><?=$newsItem->author?></em> op <?=$newsItem->date?></span><br/><?=$newsItem->intro?>
                                    <br/><br/><?=$newsItem->message?>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width="5%">&nbsp;</td> 
                </tr>
            </table>
        </td>
    </tr>
</table>
